import java.util.*;

public class Main {

    //
    public static void main1(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
        }

        int ret = 1;
        for(int i = 0; i < n; ){
            int j = i;
            while(j + 1 < n && arr[j + 1] - arr[j] <= 8) { j++;}
            ret = Math.max(ret, j - i + 1);
            i = j + 1;
        }
        System.out.println(ret);
    }

    //


}
